﻿

#region Using directives
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Pharmacy.Web.UI;
using Pharmacy.Data;
using Pharmacy.Entities;
#endregion

public partial class Admin_Po : System.Web.UI.Page
{	
    protected void Page_Load(object sender, EventArgs e)
	{
		FormUtil.RedirectAfterUpdate(GridView1, "Po.aspx?page={0}");
		FormUtil.SetPageIndex(GridView1, "page");
		FormUtil.SetDefaultButton((Button)GridViewSearchPanel1.FindControl("cmdSearch"));
    }

	protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
	{
		string urlParams = string.Format("PoId={0}", GridView1.SelectedDataKey.Values[0]);
		Response.Redirect("PoEdit.aspx?" + urlParams, true);
	}

    protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        string poID = e.CommandArgument.ToString().Trim();
        if (e.CommandName == "CustomDelete")
        {

            TList<Pharmacy.Entities.PoDetails> objPodetail = DataRepository.PoDetailsProvider.GetByPoId(poID);
            if (objPodetail.Count > 0)
            {
                Response.Write(@"<script language='javascript'>alert('Vui lòng xóa tất cả chi tiết.')</script>");

            }
            else
            {
                Pharmacy.Entities.Po objPo = new Pharmacy.Entities.Po();
                objPo.PoId = poID;
                DataRepository.PoProvider.Delete(objPo);
            }
              GridView1.DataBind();
        }
    }
}


